#include <cstdio>
#include <cmath>
/**
 * 
 * 时间复杂度：O(mn)
 * 空间复杂度：O(1)
 * 
 * 图像模糊处理
 *
 * @return 
 */
int main() {
    int arr[110][110]{};
    int n, m;
    scanf("%d %d", &n, &m);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &arr[i][j]);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i ==0 || i == n - 1 || j == 0 || j == m - 1) {
                printf("%d ", arr[i][j]);
            } else {
                int sum = arr[i][j] + arr[i - 1][j] + arr[i + 1][j] + arr[i][j - 1] + arr[i][j + 1];
                printf("%d ", (int)round(sum / 5.0)); 
            }
        }
        printf("\n");
    }


    return 0;
}